import service from "../index";

export const getPro = (params) => {
  return service({
    method: "GET",
    url: "/api/project/GetRunningProjectsByManager",
    params,
  });

};



export const AddNewProjectNotice = (params) => {
  return service({
    method: "GET",
    url: "/api/Project/AddNewProjectNotice",
    params,
  });

};

export const getAllPro = (params) => {
  return service({
    method: "GET",
    url: "/api/project/GetAllProjectV2",
    params,
  });

};


export const GetProjectList = (params) => {
  return service({
    method: "GET",
    url: "/api/project/GetProjectList",
    params,
  });

};

export const DeleteRole = (params) => {
  return service({
    method: "GET",
    url: `/api/Roles/DeleteRole`,
    params,
  });
};

export const AddOrUpdateRole = (params) => {
  return service({
    method: "GET",
    url: `/api/Roles/AddOrUpdateRole`,
    params,
  });
};

export const GetRoles = (params) => {
  return service({
    method: "GET",
    url: `/api/Roles/GetRoles`,
    params,
  });
};

export const DownloadProjectUnitsLoadTemp = (params) => {
  return service({
    method: "GET",
    url: `/api/Unit/DownloadProjectUnitsLoadTemp`,
    params,
    responseType: "blob",
  });
};


export const ModifyProjectNoticeState = (params) => {
  return service({
    method: "GET",
    url: `/api/project/ModifyProjectNoticeState`,
    params,
  });
};

export const GetAllProjectNotices = (params) => {
  return service({
    method: "GET",
    url: `/api/project/GetAllProjectNotices`,
    params,
  });
};

export const GetDepartmentFiles = (params) => {
  return service({
    method: "GET",
    url: `/api/Department/GetDepartmentAllFiles`,
    params,
  });
};


export const GetAllTrainingRecord = (params) => {
  return service({
    method: "GET",
    url: `/api/Department/GetAllTrainingRecord`,
    params,
  });
};


export const DelTrainingRecord = (params) => {
  return service({
    method: "GET",
    url: `/api/Department/DelTrainingRecord`,
    params,
  });
};

export const UploadTrainingRecordSignInSheet = (fileOid,data) => {
  return service({
    method: "POST",
    url: `/api/Department/UploadTrainingRecordSignInSheet?fileOid=${fileOid}`,
    data,
  });
};

export const SaveTrainingRecord = (data) => {
  return service({
    method: "POST",
    url: `/api/Department/SaveTrainingRecord`,
    data,
  });
};


export const UpdateTrainingRecord = (data) => {
  return service({
    method: "POST",
    url: `/api/Department/UpdateTrainingRecord`,
    data,
  });
};

export const AddProjectNotice = (params) => {
  return service({
    method: "GET",
    url: `/api/project/AddProjectNotice`,
    params,
  });
};

export const DeleteProjectUnifiedRegulationFile = (params) => {
  return service({
    method: "GET",
    url: `/api/project/DeleteProjectFile`,
    params,
  });
};

export const DeleteDepartmentFile = (params) => {
  return service({
    method: "GET",
    url: `/api/Department/DeleteDepartmentFile`,
    params,
  });
};

export const DownloadProjectUnifiedRegulationFile = (params) => {
  return service({
    method: "GET",
    url: `/api/project/DownloadProjectFile`,
    params,
    responseType: "blob",
  });
};

export const DownloadDepartmentFile = (params) => {
  return service({
    method: "GET",
    url: `/api/Department/DownloadDepartmentFile`,
    params,
    responseType: "blob",
  });
};

export const UploadProjectUnifiedRegulationFiles = (data, id, str) => {
  return service({
    method: "POST",
    url: `/api/project/UploadProjectFiles?proj_oid=${id}&file_type=${str}`,
    data,
  });
};

export const UploadDepartmentFiles = (data, str) => {
  return service({
    method: "POST",
    url: `/api/Department/UploadDepartmentFiles?file_type=${str}`,
    data,
  });
};


export const DownLoadTrainingRecordSignInSheet = (data) => {
  return service({
    method: "POST",
    url: `/api/Department/DownLoadTrainingRecordSignInSheet`,
    data,
    responseType: "blob",
  });
};


export const DownloadTrainingRecordAttachFile = (data) => {
  return service({
    method: "POST",
    url: `/api/Department/DownloadTrainingRecordAttachFile`,
    data,
    responseType: "blob",
  });
};


export const GetTrainingRecordAttachFiles = (data) => {
  return service({
    method: "POST",
    url: `/api/Department/GetTrainingRecordAttachFiles`,
    data,
  });
};


export const DeleteTrainingRecordAttachFile = (data) => {
  return service({
    method: "POST",
    url: `/api/Department/DeleteTrainingRecordAttachFile`,
    data,
  });
};


export const UploadTrainingRecordAttachFiles = (data,oid) => {
  return service({
    method: "POST",
    url: `/api/Department/UploadTrainingRecordAttachFiles?training_record_oid=${oid}`,
    data,
  });
};



export const DelTrainingRecordSignInSheet = (data) => {
  return service({
    method: "POST",
    url: `/api/Department/DelTrainingRecordSignInSheet`,
    data,
  });
};

export const GetProjectUnifiedRegulationFiles = (params) => {
  return service({
    method: "GET",
    url: "/api/project/GetProjectFiles",
    params,
  });
};

export const DeleteUnit = (params) => {
  return service({
    method: "GET",
    url: "/api/Unit/DeleteUnit",
    params,
  });
};


export const isunitUsed = (params) => {
  return service({
    method: "GET",
    url: "/api/unit/isunitUsedV2",
    params,
  });
};

export const AddUnit = (params) => {
  return service({
    method: "GET",
    url: "/api/Unit/AddUnit",
    params,
  });
};

export const AddProjectUserV2 = (data) => {
  return service({
    method: "POST",
    url: "/api/user/AddProjectUserV2",
    data,
  });
};

export const DeleteUserV2 = (params) => {
  return service({
    method: "GET",
    url: "/api/user/DeleteUserV2",
    params,
  });
};

export const ModifyUnit = (params) => {
  return service({
    method: "GET",
    url: "/api/Unit/ModifyUnit",
    params,
  });
};

export const GetUnits = (params) => {
  return service({
    method: "GET",
    url: "/api/Unit/GetUnits",
    params,
  });
};

export const GetProjectUsers = (params) => {
  return service({
    method: "GET",
    url: "/api/user/GetProjectUsers",
    params,
  });
};


export const GetProjBasicDesignData = (params) => {
  return service({
    method: "GET",
    url: "/api/project/GetProjBasicDesignData",
    params,
  });
};


export const SaveProjBasicDesignData = (params) => {
  return service({
    method: "GET",
    url: "/api/project/SaveProjBasicDesignData",
    params,
  });
};


export const AddProjectV2 = (data) => {
  delete data.date;
  delete data.professional_leader;
  delete data.team_leader;
  data.professional_leaders?.forEach((v, i) => {
    delete data.professional_leaders[i].login_pwd;
    delete data.professional_leaders[0].login_account;
    delete data.professional_leaders[0].user_dept;
  });
  data.team_leaders?.forEach((v, i) => {
    delete data.team_leaders[i].login_pwd;
    delete data.team_leaders[0].login_account;
    delete data.team_leaders[0].user_dept;
  });

  return service({
    method: "POST",
    url: "/api/project/AddProjectV2",
    data,
  });
};

export const ModifyProjectInfoV2 = (data) => {
  delete data.date;
  delete data.professional_leader;
  delete data.team_leader;
  delete data.proj_type
  delete data.create_time
  delete data.modify_time
  data.professional_leaders?.forEach((v, i) => {
    delete data.professional_leaders[i].login_pwd;
    delete data.professional_leaders[0].login_account;
    delete data.professional_leaders[0].user_dept;
  });
  data.team_leaders?.forEach((v, i) => {
    delete data.team_leaders[i].login_pwd;
    delete data.team_leaders[0].login_account;
    delete data.team_leaders[0].user_dept;
  });
  return service({
    method: "POST",
    url: "/api/project/ModifyProjectInfoV2",
    data,
  });
};

export const deleteproject = (params) => {
  return service({
    method: "GET",
    url: "/api/project/deleteproject",
    params,
  });
};

export const modifyprojectstatus = (params) => {
  return service({
    method: "GET",
    url: "/api/project/modifyprojectstatus",
    params,
  });
};

export const IsAlreadyDistributed = (data) => {
  return service({
    method: "POST",
    url: "/api/EquipFileStandReview/IsAlreadyDistributed",
    data,
  });
};


export const IsAlreadyDistributed2 = (a,b,c) => {
  return service({
    method: "POST",
    url: `/api/SafetyDesignChecklist/IsAlreadyDistributed?proj_oid=${a}&major=${b}`,
    data:c,
  });
};


export const DownloadEquipmentLoadInformationTemp = (data) => {
  return service({
    method: "POST",
    url: "/api/equipment/DownloadEquipmentLoadInformationTemp",
    data,
    responseType: "blob",
  });
};


export const ExportEquipInfo = (data) => {
  return service({
    method: "POST",
    url: "/api/equipment/ExportEquipInfo",
    data,
    responseType: "blob",
  });
};


export const IsProjHasUploadUniformRegulation = (data) => {
  return service({
    method: "POST",
    url: "/api/project/IsProjHasUploadUniformRegulation",
    data,
  });
};


export const BatchModifyEquipStatu = (data) => {
  return service({
    method: "POST",
    url: "/api/equipment/BatchModifyEquipStatu",
    data,
  });
};

export const UpdatePressureVesselQSDialyCheckRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/UpdatePressureVesselQSDialyCheckRecord",
    data,
  });
};


export const CreatePressureVesselQSDialyCheckRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/CreatePressureVesselQSDialyCheckRecord",
    data,
  });
};



export const GetAllPressureVesselQSDialyCheckRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/GetAllPressureVesselQSDialyCheckRecord",
    data,
  });
};

export const SavePressureVesselQSSchedulingMettingRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/SavePressureVesselQSSchedulingMettingRecord",
    data,
  });
};

export const UpdatePressureVesselQSSchedulingMettingRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/UpdatePressureVesselQSSchedulingMettingRecord",
    data,
  });
};


export const DelPressureVesselQSSchedulingMettingRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/DelPressureVesselQSSchedulingMettingRecord",
    data,
  });
};

export const DelPressureVesselQSDialyCheckRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/DelPressureVesselQSDialyCheckRecord",
    data,
  });
};

export const DelPressureVesselQSWeeksGovernRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/DelPressureVesselQSWeeksGovernRecord",
    data,
  });
};

export const GetAllPressureVesselQSSchedulingMettingRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/GetAllPressureVesselQSSchedulingMettingRecord",
    data,
  });
};

export const GetAllPressureVesselQSWeeksGovernRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/GetAllPressureVesselQSWeeksGovernRecord",
    data,
  });
};

export const SavePressureVesselQSWeeksGovernRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/SavePressureVesselQSWeeksGovernRecord",
    data,
  });
};

export const UpdatePressureVesselQSWeeksGovernRecord = (data) => {
  return service({
    method: "POST",
    url: "/api/Department/UpdatePressureVesselQSWeeksGovernRecord",
    data,
  });
};


export const GetDepartmentUsersV2 = (params) => {
  return service({
    method: "GET",
    url: "/Authorization/HLDECAuthorization/GetDepartmentUsersV2",
    params,
  });
};


export const delPro = (params) => {
  return new Promise((res) => {
    res([
      {
        create_time: "2022-12-13",
        end_time: "2022-12-14",
        professional_leader: "黄渤",
        proj_name: "新疆和山巨力化工有限公司16万吨",
        proj_no: "/年氯化氢循环利用项目",
        proj_no: "124",
        proj_oid: "3e49c4e4-40e6-4ce1-22996f-62765bee88af",
        proj_status: "运行中",
        team_leader: "黄渤",
      },
      {
        create_time: "2022-12-13",
        end_time: "2022-12-14",
        professional_leader: "黄1渤",
        proj_name: "新疆和山巨力化23工有限公司16万吨",
        proj_no: "/年氯化氢循环利1用项目",
        proj_no: "124",
        proj_oid: "3e49c4e4-40e6-4ce1-996f-62765bee88af",
        proj_status: "运行中",
        team_leader: "黄渤",
      },
    ]);
  });

  // 请求示例
  // return service({
  // 	method: 'GET',
  // 	url: '/api/project/GetOpenProjectByUser',
  // 	params,
  // })
};

export const getMarjorPro = (params) => {
  return new Promise((res) => {
    res([
      {
        id: "xxx",
        proSubcode: "1425主项号",
        proSubname: "主项名称",
        proRemark: "我是备2注",
      },
      {
        id: "xxx123",
        proSubcode: "142225主项号",
        proSubname: "主项名称2",
        proRemark: "我是备注",
      },
    ]);
  });

  // 请求示例
  // return service({
  // 	method: 'GET',
  // 	url: '/api/project/GetOpenProjectByUser',
  // 	params,
  // })
};

export const delMarjorTable = (params) => {
  return new Promise((res) => {
    res();
  });

  // 请求示例
  // return service({
  // 	method: 'GET',
  // 	url: '/api/project/GetOpenProjectByUser',
  // 	params,
  // })
};



export const getOptionLeader = (params) => {
  return new Promise((res) => {
    res([
      {
        value: "王汤",
        label: "王汤",
      },
    ]);
  });

};

export const getOptionTeam = (params) => {
  return new Promise((res) => {
    res([
      {
        value: "王汤",
        label: "王汤",
      },
    ]);
  });


};



export const impMarjor = (data,oid) => {

return service({
  	method: 'POST',
  	url: `/api/Unit/MultiLoadUnits?proj_oid=${oid}`,
  	data,
  })

};


